home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- Small Mech
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "M_smallmech.h"
-
-
- void smallmech_doattack_rocket (edict_t *self);
-
- static int sound_pain;
- static int sound_idle;
- static int sound_step;
- static int sound_sight;
- static int sound_windup;
- static int sound_shoot;
-
- //
- // misc
- //
-
- void smallmech_sight (edict_t *self, edict_t *other)
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- }
-
-
- void smallmech_footstep (edict_t *self)
- {
- gi.sound (self, CHAN_BODY, sound_step, 1, ATTN_NORM, 0);
- }
-
- void smallmech_windup (edict_t *self)
- {
- gi.sound (self, CHAN_WEAPON, sound_windup, 1, ATTN_NORM, 0);
- }
-
- void smallmech_idle (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
- }
-
-
- //
- // stand
- //
-
- mframe_t smallmech_frames_stand []=
- {
-
- ai_stand, 0, smallmech_idle,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, smallmech_idle,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
- mmove_t smallmech_move_stand = {FRAME_idle01, FRAME_idle13, smallmech_frames_stand, NULL};
-
- void smallmech_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &smallmech_move_stand;
- }
-
-
- //
- // walk
- //
-
- void smallmech_walk (edict_t *self);
-
-
- mframe_t smallmech_frames_walk [] =
- {
- ai_run, 35, NULL,
- ai_run, 25, NULL,
- ai_run, 15, smallmech_footstep,
- ai_run, 12, NULL,
- ai_run, 5, NULL,
- ai_run, 11, NULL,
- ai_run, 34, NULL,
- ai_run, 26, NULL,
- ai_run, 16, smallmech_footstep,
- ai_run, 14, NULL,
- ai_run, 7, NULL,
- ai_run, 11, NULL
- };
- mmove_t smallmech_move_walk = {FRAME_walk01, FRAME_walk12, smallmech_frames_walk, NULL};
-
- void smallmech_walk (edict_t *self)
- {
- self->monsterinfo.currentmove = &smallmech_move_walk;
- }
-
-
- //
- // run
- //
-
- void smallmech_run (edict_t *self);
-
- mframe_t smallmech_frames_run [] =
- {
- ai_run, 35, NULL,
- ai_run, 25, NULL,
- ai_run, 15, smallmech_footstep,
- ai_run, 12, NULL,
- ai_run, 5, NULL,
- ai_run, 11, NULL,
- ai_run, 34, NULL,
- ai_run, 26, NULL,
- ai_run, 16, smallmech_footstep,
- ai_run, 14, NULL,
- ai_run, 7, NULL,
- ai_run, 11, NULL
- };
- mmove_t smallmech_move_run = {FRAME_walk01, FRAME_walk12, smallmech_frames_run, NULL};
-
- void smallmech_run (edict_t *self)
- {
- if (self->enemy && self->enemy->client)
- self->monsterinfo.aiflags |= AI_BRUTAL;
- else
- self->monsterinfo.aiflags &= ~AI_BRUTAL;
-
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- {
- self->monsterinfo.currentmove = &smallmech_move_stand;
- return;
- }
-
- self->monsterinfo.currentmove = &smallmech_move_run;
-
- }
-
- //
- // pain
- //
-
- mframe_t smallmech_frames_pain1 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t smallmech_move_pain1 = {FRAME_pain01, FRAME_pain07, smallmech_frames_pain1, smallmech_run};
-
- void smallmech_pain (edict_t *self, edict_t *other, float kick, int damage)
- {
- if (self->health < (self->max_health / 2))
- self->s.skinnum |= 1;
-
- if (damage <= 10)
- return;
-
- if (level.time < self->pain_debounce_time)
- return;
-
- if (damage <= 30)
- if (random() > 0.2)
- return;
-
- self->pain_debounce_time = level.time + 3;
- gi.sound (self, CHAN_VOICE, sound_pain, 1, ATTN_NORM, 0);
-
- self->monsterinfo.currentmove = &smallmech_move_pain1;
- }
-
-
- //
- // attacks
- //
- void robotBlaster (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t end;
- vec3_t dir;
- int flash_number;
-
-
- flash_number = MZ2_TANK_BLASTER_3;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- right[0] = right[0] * 0.0;
- right[1] = right[1] * 0.0;
- G_ProjectSource (self->s.origin, monster_flash_offset[flash_number], forward, right, start);
-
- VectorCopy (self->enemy->s.origin, end);
- end[2] += self->enemy->viewheight;
- VectorSubtract (end, start, dir);
- gi.sound (self, CHAN_VOICE, sound_shoot, 1, ATTN_NORM, 0);
- monster_fire_blaster (self, start, dir, 15, 800, flash_number, EF_BLASTER);
- }
-
- void smallmechRocket (edict_t *self)
- {
- vec3_t forward, right;
- vec3_t start;
- vec3_t dir;
- vec3_t vec;
- vec3_t temp;
- int flash_number;
-
- if (self->s.frame == FRAME_shoot11)
- flash_number = MZ2_TANK_ROCKET_1;
- else if (self->s.frame == FRAME_shoot11)
- flash_number = MZ2_TANK_ROCKET_2;
- else // (self->s.frame == FRAME_attak330)
- flash_number = MZ2_TANK_ROCKET_3;
-
- AngleVectors (self->s.angles, forward, right, NULL);
- right[0] = right[0] * 0.0;
- right[1] = right[1] * 0.0;
- VectorCopy (self->s.origin, temp);
- temp[2] = temp[2] - 22;
- G_ProjectSource (temp, monster_flash_offset[flash_number], forward, right, start);
-
- VectorCopy (self->enemy->s.origin, vec);
- vec[2] += self->enemy->viewheight;
- VectorSubtract (vec, start, dir);
- VectorNormalize (dir);
-
- monster_fire_sidewinder (self, start, dir, 30, 250, flash_number);
- }
-
- mframe_t smallmech_frames_attack_fire_blaster [] =
- {
- ai_charge, -3, smallmech_windup, // Loop Start 22
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, -3, NULL, // Loop Start 22
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, robotBlaster,
- ai_charge, 0, NULL,
- ai_charge, -3, NULL, // Loop Start 22
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, -1, NULL // 30 Loop End
- };
- mmove_t smallmech_move_attack_fire_blaster = {FRAME_shoot01, FRAME_shoot17, smallmech_frames_attack_fire_blaster, smallmech_run};
-
- mframe_t smallmech_frames_attack_fire_rocket [] =
- {
- ai_charge, -3, smallmech_windup, // Loop Start 22
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, -3, NULL, // Loop Start 22
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, smallmechRocket,
- ai_charge, 0, NULL,
- ai_charge, -3, NULL, // Loop Start 22
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, -1, NULL // 30 Loop End
- };
- mmove_t smallmech_move_attack_fire_rocket = {FRAME_shoot01, FRAME_shoot17, smallmech_frames_attack_fire_rocket, smallmech_run};
-
- void smallmech_doattack_rocket (edict_t *self)
- {
- self->monsterinfo.currentmove = &smallmech_move_attack_fire_rocket;
- }
-
- void smallmech_attack(edict_t *self)
- {
- vec3_t vec;
- float range;
-
- VectorSubtract (self->enemy->s.origin, self->s.origin, vec);
- range = VectorLength (vec);
-
- if (random() < 0.5)
- self->monsterinfo.currentmove = &smallmech_move_attack_fire_blaster;
- else
- self->monsterinfo.currentmove = &smallmech_move_attack_fire_rocket;
-
- self->pain_debounce_time = level.time + 5.0; // no pain for a while
- }
-
-
- //
- // death
- //
-
- void smallmech_dead (edict_t *self)
- {
- VectorSet (self->mins, -16, -16, -16);
- VectorSet (self->maxs, 16, 16, 24);
- self->movetype = MOVETYPE_TOSS;
- self->svflags |= SVF_DEADMONSTER;
- self->nextthink = 0;
- gi.linkentity (self);
- }
-
-
- void smallmech_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- BecomeExplosion1(self);
- self->deadflag = DEAD_DEAD;
- }
-
-
- //
- // monster_smallmech
- //
-
- /*QUAKED monster_smallmech (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight
- */
- /*QUAKED monster_smallmech_commander (1 .5 0) (-32 -32 -16) (32 32 72) Ambush Trigger_Spawn Sight
- */
- void SP_monster_smallmech (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- self->s.modelindex = gi.modelindex ("models/monsters/smallmech/tris.md2");
- VectorSet (self->mins, -16, -16, -40);
- VectorSet (self->maxs, 16, 16, 24);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
-
- sound_pain = gi.soundindex ("smallmech/pain.wav");
- sound_idle = gi.soundindex ("smallmech/idle.wav");
- sound_step = gi.soundindex ("smallmech/step.wav");
- sound_windup = gi.soundindex ("smallmech_windup.wav");
- sound_sight = gi.soundindex ("smallmech/sight.wav");
- sound_shoot = gi.soundindex ("smallmech/laser.wav");
-
- self->max_health = 150;
- self->health = self->max_health;
- self->gib_health = -200;
- self->classname = "monster_mech";
-
- self->mass = 500;
-
- self->pain = smallmech_pain;
- self->die = smallmech_die;
- self->monsterinfo.stand = smallmech_stand;
- self->monsterinfo.walk = smallmech_walk;
- self->monsterinfo.run = smallmech_run;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = smallmech_attack;
- self->monsterinfo.melee = NULL;
- self->monsterinfo.sight = smallmech_sight;
- self->monsterinfo.idle = smallmech_idle;
-
- gi.linkentity (self);
-
- self->monsterinfo.currentmove = &smallmech_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
-
- walkmonster_start(self);
- }
-